package action;

import java.util.Map;

import com.opensymphony.xwork2.ActionContext;

import dao.DaoFactory;
import dao.UserDao;

import entity.User;

public class Login {
	private String name;
	private String pwd;
	private String dir;//用于接收struts.xml中的param元素值
	
	public String execute() throws Exception{
		User u = DaoFactory.getInstance(UserDao.class).findByUserName(name);
		if(u!=null&&u.getPassWord().equals(pwd)){
			System.out.println(dir);
			Map<String,Object> session = ActionContext.getContext().getSession();
			session.put("user", name);//将用户名写入session
			//session.get("user");
			return "success";
		}
		return "fail";
	}
	public String getName() {
		return name;
	}
	public String getPwd() {
		return pwd;
	}
	public void setName(String name) {
		this.name = name;
	}
	public void setPwd(String pwd) {
		this.pwd = pwd;
	}
	public String getDir() {
		return dir;
	}
	public void setDir(String dir) {
		this.dir = dir;
	}
	
}
